/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014年12月27日         cassie
 */

package com.coocaa.launcher.pattern.normal.item;

import android.animation.Animator;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;

import com.coocaa.launcher.framework.launcherhost.view.AppItemView;
import com.coocaa.x.uipackage.SkinManager;
import com.coocaa.x.uipackage.SkinManager.OnThemeChangeListener;
import com.tianci.appstore.R;
import com.tianci.appstore.ui.widget.CatchImageView;
import com.tianci.appstore.utils.SkyConstants;

public class TempAddView extends AppItemView implements OnThemeChangeListener {
    private ImageView image;
    public static String viewType = "hot_seat_temp_add";

    public TempAddView(Context context) {
        super(context, viewType);
        // TODO Auto-generated constructor stub
        image = new CatchImageView(context);
        this.addView(image, new LayoutParams(SkyConstants.Div(116),
                SkyConstants.Div(116), Gravity.CENTER));
        SkinManager.getInstance().setBackgroundResource(image, R.drawable.add_icon);
        this.setAlpha(0);
        this.setFocusable(true);
        this.setVisibility(View.INVISIBLE);
    }

    @Override
    public void onThemeChange() {
        // TODO Auto-generated method stub
        SkinManager.getInstance().setBackgroundResource(image, R.drawable.add_icon);
    }

    public void show(int duration) {
        this.setVisibility(View.VISIBLE);
        this.setFocusable(true);
        this.animate().alpha(1.0f).setDuration(duration).setListener(null);
    }

    public void hide(int duration) {
        this.setFocusable(false);
        this.animate().alpha(0).setDuration(duration).setListener(hideListener);
    }

    private Animator.AnimatorListener hideListener = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            // TODO Auto-generated method stub
            TempAddView.this.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
            // TODO Auto-generated method stub
        }
    };

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub

    }
}
